<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLiveProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('live_products', function (Blueprint $table) {
            $table->id()->comment('直播商品表');
            $table->integer('product_id')->comment('商品ID')->index();
            $table->integer('audit_id')->comment('审核ID')->index();
            $table->string('cover_url')->comment('商品图片链接');
            $table->decimal('price',10,2)->comment('原价');
            $table->decimal('live_price',10,2)->comment('直播价');
            $table->string('url')->nullable()->comment('商品小程序链接');
            $table->string('price_type')->default('price')->comment('价格类型（price:一口价，此时读price字段; priceRange:价格区间，此时price字段为左边界，live_price字段为右边界; discountPrice:折扣价，此时price字段为原价，live_price字段为现价；）');
            $table->decimal('cost_price',10,2)->nullable()->comment('成本价');
            $table->integer('sort')->default(0)->comment('商品排序');
            $table->tinyInteger('is_show')->default(1)->comment('是否显示 0:不显示 1:显示');
            $table->string('audit_status',50)->default('notApproved')->comment('审核状态（notApproved：未审核，review：审核中，approved:审核通过，auditFailed:审核失败）');
            $table->tinyInteger('third_part_tag')->default(0)->comment('0：表示是为 API 添加商品，1:否则是直播控制台添加的商品');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('live_products');
    }
}
